package org.opens.javaskill.itextpdf;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfDocument;
import com.itextpdf.text.pdf.PdfWriter;
import org.junit.Test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;


public class CreatePdf {

    /**
     * 说明:
     * <pre>
     *     1. 创建一个新的pdf.
     * </pre>
     */
    @Test
    public void test18() throws FileNotFoundException, DocumentException {
        Document document = new Document(PageSize.A4);
        FileOutputStream fileOutputStream = new FileOutputStream(new File("D:\\test\\a.pdf"));
        PdfWriter.getInstance(document, fileOutputStream);
        document.addTitle("我是标题");
        document.open();
        document.add(new Paragraph("Hello World1!"));
        document.add(new Paragraph("Hello World2!"));
        document.add(new Paragraph("Hello World3!"));
        document.add(new Paragraph("Hello World4!"));
        document.close();
    }
}
